import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controller/demo_controller.dart';

class GetBuilderDemoPage extends StatelessWidget {
  const GetBuilderDemoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('GetBuilder 状态管理示例'),
        leading: IconButton(
          icon: const Icon(Icons.home),
          onPressed: () => Get.offAllNamed('/'),
        ),
      ),
      body: Center(
        child: GetBuilder<DemoController>(
          init: DemoController(),
          builder: (controller) => Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('count: ${controller.count}',
                  style: const TextStyle(fontSize: 24)),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: controller.increment,
                child: const Text('count+1'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
